﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace CommandReceiver
{
    public class Win32API
    {
        [DllImport("User32.dll", EntryPoint = "SendMessage")]
        private static extern int SendMessage(
        IntPtr hWnd,
        int Msg,
        int wParam,
        int lParam
        );

        /// <summary>
        /// 
        /// </summary>
        /// <param name="handle"></param>
        public static void MouseDown(IntPtr handle)
        {
            SendMessage(handle, 0x0201, 0, 0);

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="handle"></param>
        public static void MouseUp(IntPtr handle)
        {
            SendMessage(handle, 0x0202, 0, 0);
        }

        //按下鼠标左键
        public static int WM_LBUTTONDOWN = 0x0201;
        //释放鼠标左键
        public static int WM_LBUTTONUP = 0x0202;

        const int MOUSEEVENTF_MOVE = 0x0001;      //移动鼠标 
        const int MOUSEEVENTF_LEFTDOWN = 0x0002; //模拟鼠标左键按下 
        const int MOUSEEVENTF_LEFTUP = 0x0004; //模拟鼠标左键抬起 
        const int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下 
        const int MOUSEEVENTF_RIGHTUP = 0x0010; //模拟鼠标右键抬起 
        const int MOUSEEVENTF_MIDDLEDOWN = 0x0020; //模拟鼠标中键按下 
        const int MOUSEEVENTF_MIDDLEUP = 0x0040; //模拟鼠标中键抬起 
        const int MOUSEEVENTF_ABSOLUTE = 0x8000; //标示是否采用绝对坐标 
    }
}
